
<template>
  <div id="cesiumContainer"></div>
</template>
    
  
<script>
// import * as Cesium from "cesium";
// import "cesium/Source/Widgets/widgets.css";
import { defineComponent, ref, watch } from "vue";

let viewer = ref(null);
const play = () => {
  console.log("cesiumMap");
};

export default {
  props: {
    tileSet:{
      default:""
    }
  },
  setup() {
    return {
      viewer
    };
  },
  watch: {
    tileSet(newValue, oldValue) {
      console.log(newValue, oldValue);
    }
  },
  mounted() {

    // console.log(this.tileSet)
    Cesium.Camera.DEFAULT_VIEW_RECTANGLE = Cesium.Rectangle.fromDegrees(
      119.9, 30.7501282784158, 121.33, 31.9645982738191
    ); // 设置相机默认范围为自定义区域
    // Cesium.Camera.DEFAULT_VIEW_FACTOR = 0



    let _viewer = new Cesium.Viewer("cesiumContainer", {
      animation: false,
      fullscreenButton: false,
      geocoder: false,
      homeButton: false,
      infoBox: false,
      sceneModePicker: false,
      // selectionIndicator: false,
      timeline: false,
      navigationHelpButton: false,
      baseLayerPicker: false,
      // navigationInstructionsInitiallyVisible: false,
      // imageryProvider: new Cesium.ArcGisMapServerImageryProvider({

      //   url: "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"
      // })
    });



    if (Cesium.FeatureDetection.supportsImageRenderingPixelated()) {
      //判断是否支持图像渲染像素化处理
      _viewer.resolutionScale = window.devicePixelRatio
    }
    _viewer.scene.postProcessStages.fxaa.enabled = true

    this.viewer = _viewer;
    // 不显示底图
    // _viewer.imageryLayers.get(0).show = false;

    //鼠标右键切换视角
    _viewer.scene.screenSpaceCameraController.tiltEventTypes = [
      Cesium.CameraEventType.RIGHT_DRAG,
    ];
    //隐藏原生logo
    _viewer._cesiumWidget.creditContainer.style.display = "none";

    _viewer.scene.logarithmicDepthBuffer = false;

    //深度检测
    // _viewer.scene.globe.depthTestAgainstTerrain = true;
    // viewer.scene.globe.enableLighting = false;
    //显示帧速
    _viewer.scene.debugShowFramesPerSecond = true;
    //关闭灯光
    _viewer.scene.globe.enableLighting = false;
    //关闭阴影
    _viewer.shadows = false;
    //修正光照
    // _viewer.scene.light = new Cesium.DirectionalLight({
    //     direction: new Cesium.Cartesian3(0.35492591601301104, -0.8909182691839401, -0.2833588392420772),
    //     // direction: Cesium.Cartesian3.fromDegrees(113.200150, 21.990197, 1000),
    //     // color: Cesium.Color.fromCssColorString("yellow"),
    //     intensity: 1
    // });

    // _viewer.scene.skyBox.show = false;
    // _viewer.scene.backgroundColor = new Cesium.Color.fromCssColorString(
    //     "#0050A4"
    // );
    _viewer.scene.sun.show = false;
    _viewer.scene.moon.show = false;
    // _viewer.scene.globe.show = false;
    _viewer.scene.skyAtmosphere.show = false; //隐藏大气圈


    if (this.tileSet) {
      let tileset = new Cesium.Cesium3DTileset(this.tileSet);

      _viewer.scene.primitives.add(tileset);
      _viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.0, -0.3, 0.0));
    }


  },
};
</script>
  
<style scoped>
#cesiumContainer {
  height: 100%;
  width: 100%;
  margin: 0;
  /* position: fixed; */
}
</style>
  